home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: HELP! Modifying the EOF in a file!
- Date: 14 Mar 1996 17:00:10 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4iafeqINNbqp@anvil.ugrad.cs.ubc.ca>
- References: <4i585k$4ia@news.netam.net>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <4i585k$4ia@news.netam.net>,
- The Bowling Green Connection <bgc@alpha.netam.net> wrote:
- >I am having trouble shortening the size of a text file...
- >Suppose I have a text file with 3 lines of data, then I
- >run this program:
- >
- >void main() {
- > FILE *dat;
- > dat=fopen("file.txt", "r+");
- > fprintf(dat, "Hello! %c", EOF);
- > fclose(dat);
- >}
- >
- >Why doesn't the EOF character chop off the remaining two lines?
- >When I print out the file after running this program, the ONLY thing
- >that changed was the first few characters.. The other two lines
- >still remain.. HELP!
-
- I think what everybody is trying to tell you, and failing miserably, is that
- EOF is not actually part of the contents of a stream. It is a ``sentinel''---a
- value returned from the file manipulation routines to indicate that there
- are no more characters. It is not part of the file, it's just a special return
- value guaranteed to be different from every character.
-
- Without this special marker it would be awkward for these routines to signal
- the end of file condition.
- --
-
-